import { createStore } from "vuex";
import persisted from "vuex-persistedstate";

const store = createStore({
  plugins: [
    persisted({
      storage: sessionStorage,
    }),
  ],
  state: {
    // token
    token: "",
    // token:sessionStorage.getItem('token'),
    //  菜单数据
    MenuList: [],
    // 个人信息
    Info: {},
    // 补货列表
    shop: [],
    // 详情数据
    detail: [],
    detailList: [],
  },
  getters: {
    token(_state) {
      return _state.token;
    },
    MenuList(_state) {
      return _state.MenuList;
    },
    Info(_state) {
      return _state.Info;
    },
    shop(_state) {
      return _state.shop;
    },
    detail(_state) {
      return _state.detail
    },
    detailList(_state) {
      return _state.shopDataRow
    },
  },

  mutations: {
    settoken(_state, _token) {
      _state.token = _token;
    },
    setMenuList(_state, _MenuList) {
      _state.MenuList = _MenuList;
    },
    setInfo(_state, _Info) {
      _state.Info = _Info;
    },
    setSolp(_state, _solp) {
      _state.shlp = _solp;
    },
    setDetail(_state, _detail) {
      _state.detail = _detail
  
    },
    setdetailList(_state, _shopDataRow){
      _state.shopDataRow = _shopDataRow
    },
  },
    actions: {
      removeToken(_state) {
        _state.commit("settoken");
        sessionStorage.removeItem("token");
      },
    },
  });
export default store;
